<%--
  Created by IntelliJ IDEA.
  User: TLY
  Date: 2022/12/8
  Time: 11:00
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@include file="./common/taglibs.jsp"%>
${jquery_js}
${validate_jquery_js}
${form_jquery_js}



<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>理发店业务管理系统</title>
  <link type="text/css" rel="stylesheet" href="${ctx}/css/style.css" />
<%--  <script type="text/javascript" src="${ctx}/scripts/index.js"></script>--%>
<%--  <script type="text/javascript" src="${ctx}/js/jquery-1.12.4.js"></script>--%>
<%--  <script type="text/javascript" src="${ctx}/scripts/index.js"></script>--%>


</head>
<body>
<div class="mydiv">
<div id="register" class="wrap">
  <div class="shadow">
    <em class="corner lb"></em>
    <em class="corner rt"></em>
    <div class="box">
      <h1>欢迎使用理发店业务管理系统</h1>
      <form id="myform" method="post" action="#" >
        <table>
          <tr>
            <td class="field">管理员名：</td>
            <td>
              <input class="text" type="text" id="adminname" name="adminname" maxlength="20"/>
              <span></span>
            </td>
          </tr>
          <tr>
            <td class="field">登录密码：</td>
            <td>
              <input class="text" type="password" id="adminpwd" name="adminpwd" maxlength="20"/>
              <span></span>
            </td>
          </tr>
          <tr>
            <td></td>
            <td><label class="ui-green"><input type="button" name="button" id="btn" value="立即登录" /></label></td>
          </tr>
        </table>
      </form>
    </div>
  </div>
  <div class="clear"></div>
</div>
</div>
<div id="footer">
  安徽大学江淮学院 2019级 计算机科学与技术专业 陶龙宇 学号JB194033
</div>

<script type="text/javascript">
  $(function(){
    $("#btn").click(function(){
      if($("#myform").valid()){
      var adminname = $("#adminname").val();
      var adminpwd = $("#adminpwd").val();
      $.ajax({
        url:"${ctx}/admin/login",
        type:"post",
        data:{"adminname":adminname,"adminpwd":adminpwd},
        dataType:"json",
        success:function (result){
          alert(result.msg);
          if (result.code==10000){
            location.href="${ctx}/index.jsp";
          }else {

            alert(result.msg())
            location.href="${ctx}/login.jsp";
          }
        }

      })
      }
    })

    $("#myform").validate({
      rules:{
        "adminname":{
          required:true,
        },
        "adminpwd":{
          required:true,
          minlength:3
        }
      },
      messages:{
        "adminname":{
          required:"用户名不能为空"
        },
        "adminpwd":{
          required:"密码不能为空",
          minlength:"密码长度不能低于3位"
        }
      }
    })

  })

</script>

</body>
</html>

